from matplotlib import pyplot as plt
import numpy as np

x = ['bias_add', 'conv2d', 'matmul']
y_weighted = [8112, 10472, 7157]
y_qlearning = [15000, 14994, 14999]

bar_width = 0.2

plt.title('Weighted vs. Q-Learning Sampling')
plt.bar(x=range(len(x)), height=y_qlearning, label='q-learning sampling', width=bar_width)
plt.bar(x=np.arange(len(x))+bar_width, height=y_weighted, label='weighted sampling', width=bar_width)

for x_, y_ in enumerate(y_qlearning):
    plt.text(x_ - bar_width / 2 + 0.02, y_ - 800, '{0}'.format(y_), ha='left', va='bottom', fontsize=7)

for x_, y_ in enumerate(y_weighted):
    plt.text(x_ + bar_width / 2 + 0.03, y_ + 100, '{0}'.format(y_), ha='left', va='bottom', fontsize=7)

plt.ylabel("Successful sample(s)",fontsize=7)
plt.xlabel("Op(s)",fontsize=7)
plt.xticks(np.arange(len(x))+bar_width/2, x, fontsize=7)
plt.yticks(fontsize=7)
plt.legend(loc='lower right', fontsize=9)

# plt.rcParams['figure.figsize'] = (28, 21)

plt.show()